
import numpy as np
import time
# from casadi import *

def space_parameters():
    """ The space parameters"""
    Hx=500# dimensions in meters
    Hy=500
    Hz=1
    NX=100 # Number of nodes in the x-direction
    NY=36 # Number of nodes in the y-direction
    NZ=5 # Number of nodes in the z-direction
    dx=Hx/(NX-1) #distance between nodes in the x-direction
    dy=Hy/(NY-1) #distance between nodes in the y-direction
    dz=Hz/(NZ-1) #distance between nodes in the z-direction
    NP=NY*NX # number of nodes in he x-y plane
    NN=NP*NZ # total number of nodes
    Nx=NN # Total number of states
    Nw=Nx # the dimension of the noise term which is equal to the number of states
    Ny=Nx #
    Nv=Ny
    return NX,NY,NZ,dx,dy,dz,NP,NN,Nx,Nw,Ny,Nv

def circular_parameters():
    """ The space parameters"""
    Hr=290# The radius of the field
    Ht=0.5*np.pi
    Hz=0.32# The depth of the soil
    Nr=30# Number of nodes in the r-direction
    Nt=17 # Number of nodes in the theta-direction
    Nz=10 # Number of nodes in the z-direction
    dr=Hr/(Nr-1) #distance between nodes in the x-direction
    dt=Ht/(Nt-1)#angle between nodes in the theta-direction
    dz=Hz/(Nz-1) #distance between nodes in the z-direction
    Np=Nt*Nr # number of nodes in he x-y plane
    NN=Np*Nz # total number of nodes
    N_p = 5*Np # The total number of parameters to be estimated
    Nx=NN # Total number of states
    Nw=Nx # the dimension of the noise term which is equal to the number of states
    Ny=Nx #
    Ny = Nr
    Nv = Ny
    Nx_aug = Nx + N_p
    sigma_pnts = 10 
    return Nr,Nt,Nz,dr,dt,dz,Np,NN,Nx,Nw,Ny,Nv,N_p, Nx_aug,sigma_pnts

def time_parameters():
    """ The time parameters"""
    DeltaT =10*60 # Time step(The MHE sampling time i.e the time after which the measurement is obtained expressed in seconds)
    T_irrig=86400
    Tsim = 720*1200  # Simulation time
    Nsim = int(Tsim/DeltaT) # Number of times simulation is done.
    DeltaT_internal =1*60  # The samplinng time within the mhe sampling time.
    Nsim_internal = int(DeltaT/DeltaT_internal) # The number of times the simulation is done within the MHE sampling time
    return DeltaT, Tsim, Nsim

def cmatrix_single(Nx):
    CMatrix = np.eye(Nx) # the c-matrix
    return CMatrix

def Loam():
  pars={}
  pars['thetaR']=0.078
  pars['thetaS']=0.43
  pars['alpha']=3.6
  pars['n']=1.56
  pars['m']=1-1/pars['n']
  pars['Ks']=0.00000288889
  pars['neta']=0.5
  pars['Ss']=0.00001
  return pars

def clayey_loam():
  pars={}
  pars['thetaR'] = 0.095
  pars['thetaS'] = 0.41
  pars['alpha'] = 1.9
  pars['n'] = 1.31
  pars['m']=1-1/pars['n']
  pars['Ks']= 0.000072222
  pars['neta']=0.5
  pars['Ss']=0.00001
  return pars